package com.csf.cs.server;

import java.net.InetSocketAddress;
import java.util.concurrent.Executors;
import java.util.logging.Logger;

import org.jboss.netty.bootstrap.ServerBootstrap;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelFactory;
import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;

import com.csf.cs.pipeline.PipeLineFactory;

/**
 * Main Server Class
 * @author suji
 *
 */
public class ConnectionService {
	
	public static void main(String[] args) {
	    final Logger logger = Logger.getLogger(ConnectionService.class.getName());

		ChannelFactory factory = new NioServerSocketChannelFactory(Executors
				.newCachedThreadPool(), Executors.newCachedThreadPool());
		ServerBootstrap bootstrap = new ServerBootstrap(factory);
		bootstrap.setPipelineFactory(new PipeLineFactory());
		bootstrap.setOption("child.tcpNoDelay", true);
		bootstrap.setOption("child.keepAlive", true);
		System.out.println("Server starting at 8080");
		Channel channel = bootstrap.bind(new InetSocketAddress(8080));
		System.out.println("Server started at 8080");
	}

}
